package top.tenebrous.yzl.im.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ChannelType {

    CLOSE_CHANNEL("1","close"),
    MESSAGE_CHANNEL("2","on_message"),
    SEND_CHANNEL("3","send"),
    CUSTOM_CHANNEL("4","custom"),
    ;

    private final String code;
    private final String value;

    private ChannelType(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public static ChannelType getMessageType(String code) {
        for (ChannelType channelType : values()) {
            if (Objects.equals(channelType.code, code)) {
                return channelType;
            }
        }
        throw new IllegalArgumentException("unknown data type code");
    }

}
